package com.zznj.xzjc.adapter.index;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zznj.xzjc.R;
import com.zznj.xzjc.bean.index.DictionaryData;
import java.util.List;

import androidx.annotation.Nullable;

/**
 * 描述：添加类的描述
 *
 * @author wx5e48d604c2885118
 * @time 2020/4/7
 */
public class DictionaryAdapter extends BaseQuickAdapter<DictionaryData, BaseViewHolder> {

    public DictionaryAdapter(int layoutResId, @Nullable List<DictionaryData> data) {
        super(layoutResId, data);
    }

    private int selectPosition = -1;

    public void setSelectPosition(int position) {
        this.selectPosition = position;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, DictionaryData item) {
        TextView content = helper.getView(R.id.content);
        content.setText(item.getDtName());
        ImageView selectImage = helper.getView(R.id.selectImage);

        if (helper.getAdapterPosition() == selectPosition) {
            selectImage.setVisibility(View.VISIBLE);
        } else {
            selectImage.setVisibility(View.GONE);
        }
    }
}
